#ifndef FUNCTOR_HPP
#define FUNCTOR_HPP

namespace talos
{

template< class __class__ >
class Functor
{
	public:
		Functor(__class__* anInstance = NULL, void* (__class__::*aFunction)(void*) = NULL, void* someArgs = NULL);
		virtual ~Functor();

		void* start();

		int startThreaded( const pthread_attr_t* attr = NULL );

		static void* apply( void* aFunctor );

	private:
		__class__* m_instance;
		pthread_t* m_thr;
		void* (__class__::*m_function)( void* );
		void* m_args;
};

template< class __class__ >
class DestroyFunctor : public Functor< __class__ >
{
	public:
		DestroyFunctor(
				__class__* anInstance,
				void* (__class__::*aFunction)(void*),
				void* someArgs,
				bool threadedLaunch = false,
				pthread_t* thr = NULL,
				pthread_attr_t* attr = NULL);

		~DestroyFunctor();

	private:
		bool threaded;
		pthread_t* thread;
		pthread_attr_t* attribute;
};

#include "Functor.tem"

}

#endif // FUNCTOR_HPP
